using TerritoryGame.Domain.Entities.App;
using TerritoryGame.Application.Dtos;

namespace TerritoryGame.Application.Interfaces;

/// <summary>
/// 游戏缓存服务接口
/// </summary>
public interface IGameCacheService
{
    /// <summary>
    /// 缓存游戏房间信息
    /// </summary>
    Task<bool> CacheGameRoomAsync(GameRoom room);
    
    /// <summary>
    /// 获取缓存的游戏房间
    /// </summary>
    Task<GameRoom?> GetGameRoomAsync(string roomId);
    
    /// <summary>
    /// 删除游戏房间缓存
    /// </summary>
    Task<bool> RemoveGameRoomAsync(string roomId);
    
    /// <summary>
    /// 缓存玩家信息
    /// </summary>
    Task<bool> CachePlayerAsync(string roomId, Player player);
    
    /// <summary>
    /// 获取房间内所有玩家
    /// </summary>
    Task<List<Player>> GetRoomPlayersAsync(string roomId);
    
    /// <summary>
    /// 移除玩家缓存
    /// </summary>
    Task<bool> RemovePlayerAsync(string roomId, Guid playerId);
    
    /// <summary>
    /// 缓存涂色动作
    /// </summary>
    Task<bool> CachePaintActionAsync(string roomId, PaintAction action);
    
    /// <summary>
    /// 获取房间的涂色动作历史
    /// </summary>
    Task<List<PaintAction>> GetPaintActionsAsync(string roomId, int limit = 100);
    
    /// <summary>
    /// 更新玩家分数
    /// </summary>
    Task<bool> UpdatePlayerScoreAsync(string roomId, Guid playerId, double score);
    
    /// <summary>
    /// 获取房间排行榜
    /// </summary>
    Task<List<RoomLeaderboardEntry>> GetRoomLeaderboardAsync(string roomId);
    
    /// <summary>
    /// 设置房间状态
    /// </summary>
    Task<bool> SetRoomStatusAsync(string roomId, string status);
    
    /// <summary>
    /// 获取房间状态
    /// </summary>
    Task<string?> GetRoomStatusAsync(string roomId);
    
    /// <summary>
    /// 设置房间过期时间
    /// </summary>
    Task<bool> SetRoomExpiryAsync(string roomId, TimeSpan expiry);
    
    /// <summary>
    /// 获取在线房间列表
    /// </summary>
    Task<List<string>> GetOnlineRoomsAsync();
    
    /// <summary>
    /// 添加在线房间
    /// </summary>
    Task<bool> AddOnlineRoomAsync(string roomId);
    
    /// <summary>
    /// 移除在线房间
    /// </summary>
    Task<bool> RemoveOnlineRoomAsync(string roomId);
}
